package marksys.free.com.marksys.utils;

import android.content.Context;
import android.widget.Toast;

import marksys.free.com.marksys.nettool.Constant;
import marksys.free.com.marksys.ui.user.LoginActivity;

public class ShowErrTool {
    public static void show(int code, Context application, String message) {

        switch (code) {
            case 0:
                return;
            case 3001:

                // TODO: 2018/8/23
                Toast.makeText(application, "请重新登陆..", Toast.LENGTH_SHORT).show();

                SharedPreferencesUtils.removeSync(Constant.UserToken);

                ActivityManager.getInstance().starWithClearTask(LoginActivity.class, null);
                        /*Intent dialogIntent = new Intent(application, LoginActivity.class);
                        dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_NO_HISTORY);
                        application.startActivity(dialogIntent);*/

                break;
            case 3003:
                Toast.makeText(application, "用户名或密码不正确", Toast.LENGTH_SHORT).show();
                break;
            case 4001:
                Toast.makeText(application, "参数错误", Toast.LENGTH_SHORT).show();
                break;
            case 5001:
                Toast.makeText(application, "服务器发生错误", Toast.LENGTH_SHORT).show();
                break;
            case 5002:
                Toast.makeText(application, "数据保存失败", Toast.LENGTH_SHORT).show();
                break;
            case 5003:
                Toast.makeText(application, "数据删除失败", Toast.LENGTH_SHORT).show();
                break;
            case 999:
                Toast.makeText(application, "网络异常" + message, Toast.LENGTH_SHORT).show();
                break;
            default:
                Toast.makeText(application, "未知错误 : " + message, Toast.LENGTH_SHORT).show();
                break;
        }


    }
}
